package dinghan.workflow.kq.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.weaver.formmodel.util.DateHelper;

import dinghan.workflow.kq.entity.JiaBanAppDT;
import dinghan.workflow.kq.service.JiabanDetailService;
import dinghan.workflow.kq.service.impl.JiaBanServiceImpl;

public class JiaBanDTCheckOperator implements KQDTCheckOperator<JiaBanAppDT> {
	
	private JiabanDetailService jiabanService = new JiaBanServiceImpl();
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	
	@Override
	public void executeAllDTCheck() {
		List<JiaBanAppDT> allCheckinJiaBangDT = this.getAllCheckingJiaBanDT();
		for(JiaBanAppDT jbAppDT : allCheckinJiaBangDT){
			this.executeCheck(jbAppDT);
		}
	}
	
	@Override
	public void executeCheck(JiaBanAppDT jiabanAppDT) {
		
	}
	
	/**
	 * 获取所有需要核定的明细列表
	 * @return
	 */
	private List<JiaBanAppDT> getAllCheckingJiaBanDT(){
		
		List<JiaBanAppDT> allJiaBangDT = 
				jiabanService.queryListBySEDate("", DateHelper.dayMove(this.sdf.format(new Date()), -1));
		
		List<JiaBanAppDT> allCheckinJiaBangDT = new ArrayList<JiaBanAppDT>();
		
		for(JiaBanAppDT jd : allJiaBangDT){
			if(jd.getHdzt() == 0){	//状态是0的明细是未核定的明细
				allCheckinJiaBangDT.add(jd);
			}
		}
		
		allJiaBangDT = null;
		
		return allCheckinJiaBangDT;
	}
}
